/* ---------------------------------------------------------------------------------------------------------------
 * @Copyright	Quadrangle Systems Inc.
 * @Title		ApiCaller.java   
 * @author 		Peak Zhang
 * @date 		2014-07-16
 * @Description: 
 *				Implements all api service calling
 * ---------------------------------------------------------------------------------------------------------------
 */
package com.qs.education.bean.caller;

import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import com.alibaba.fastjson.JSONObject;
import com.qs.education.bean.api.PageBean;
import com.qs.education.bean.api.ResponseBase;
import com.qs.education.bean.api.ResponseBean;
import com.qs.education.bean.api.ResponseListBean;
import com.qs.education.bean.beans.EducationAdminResponse;
import com.qs.education.bean.beans.EducationClassBean;
import com.qs.education.bean.beans.EducationGradeBean;
import com.qs.education.bean.beans.EducationGroupResponse;
import com.qs.education.bean.beans.EducationHomeWorkResponse;
import com.qs.education.bean.beans.EducationHomeWorkStudentResponse;
import com.qs.education.bean.beans.EducationSMSResponse;
import com.qs.education.bean.beans.EducationSchoolBean;
import com.qs.education.bean.beans.EducationSchoolResponse;
import com.qs.education.bean.beans.EducationStudentBean;
import com.qs.education.bean.beans.EducationStudentResponse;
import com.qs.education.bean.beans.EducationSubjectBean;
import com.qs.education.bean.beans.EducationTeacherGradeClassResponse;
import com.qs.education.bean.beans.EducationTeacherResponse;
import com.qs.education.bean.entity.EducationGroup;
import com.qs.education.bean.entity.EducationHomeWork;
import com.qs.education.bean.entity.EducationHomeWorkQuestion;
import com.qs.education.bean.entity.EducationHomeWorkStudent;
import com.qs.education.bean.entity.EducationQuestion;
import com.qs.education.bean.entity.EducationSMS;
import com.qs.education.bean.entity.EducationSchool;
import com.qs.education.bean.entity.EducationStudent;
import com.qs.education.bean.entity.EducationSubject;
import com.qs.education.bean.entity.EducationSubjectUnit;
import com.qs.education.bean.entity.EducationSubjectLesson;
import com.qs.education.bean.entity.EducationTeacher;
import com.qs.education.bean.http.BeanResponseHandler;
import com.qs.education.bean.http.HttpRequestCaller;
import com.qs.education.bean.http.HttpRequestCaller.RequestMethod;
import com.qs.education.bean.http.ResponseHandlerChain;
import com.qs.education.bean.http.StringResponseHandler;
import com.qs.education.bean.service.IEducationPahtService;
import com.qs.education.bean.utils.ApiRequestHelper;
import com.qs.education.bean.utils.JsonUtil;

import net.sf.ehcache.hibernate.management.impl.BeanUtils;

/**
 * @class ApiCaller
 * @author Brooks
 * @description api的接口,系统中所有的调用都会在此类中
 * @date Oct 24, 2018
 */
@Service("apiCallers")
public class ApiCaller {
	@Autowired
	public IEducationPahtService iEducationPahtService;

	private RestTemplate restTemplate = new RestTemplate();
	
	/**
	 * Create a ResponseHandlerChain instance with StringResponseHandler and
	 * BeanResponseHandler
	 * 
	 * @author Peak Zhang
	 * @param clazz which will be used for initializing BeanResponseHandler
	 * @return
	 */
	private static HttpRequestCaller createCaller(Class<? extends ResponseBase> clazz) {
		ResponseHandlerChain chain = ResponseHandlerChain.create();
		chain.register(new StringResponseHandler());
		chain.register(new BeanResponseHandler(clazz));
		HttpRequestCaller caller = HttpRequestCaller.create(chain);
		ApiRequestHelper.addCommonHeaders(caller);
		return caller;
	}

	// -------------------------------- SMS-------------------------------------
	
	/**
	 * @Description 查询所有SMS
	 * @author Jason
	 * @date Nov 16, 2018
	 * @param sms
	 * @param page
	 * @param size
	 * @return
	 */
	public PageBean getSMSList(EducationSMS sms, Integer currentPage, Integer pageSize) {
		
		HttpRequestCaller caller = createCaller(PageBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GET_SMSLIST_PATH;
		Map<String, String> params = new HashMap<String, String>();
		params.put("sms", JsonUtil.beanToJson(sms));
		params.put("currentPage", currentPage.toString());
		params.put("pageSize", pageSize.toString());
		Object request = caller.request(path, RequestMethod.GET,params);
		PageBean pageBean = (PageBean) request;
		
		return pageBean;
	}
	
	/**
	 * @Description 根据ID删除SMS
	 * @author Jason
	 * @date Nov 19, 2018
	 * @param id
	 * @return
	 */
	public ResponseBean deleteSMSById(Integer Id) {
		
		HttpRequestCaller caller = createCaller(ResponseBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_DELETE_SMSLIST_PATH;
		Map<String, String> params = new HashMap<String, String>();
		params.put("Id", Id.toString());
		ResponseBean response = (ResponseBean) caller.request(path, RequestMethod.GET,params);
		
		return response;
	}

	
	/**
	 * @author Warren
	 * @param mobile 手机号
	 * @param code   验证码
	 * @return EducationSMSResponse
	 * @description 用户发送的验证码与后台存储的进行校验
	 * @date Nov 5, 2018
	 */
	public ResponseBean checkSMS(String mobile, String code) {
		HttpRequestCaller caller = createCaller(ResponseBean.class);
		Map<String, String> params = new HashMap<String, String>();
		params.put("mobile", mobile);
		params.put("code", code);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_SMS_CHECK;
		ResponseBean response = (ResponseBean) caller.request(path, RequestMethod.GET, params);
		return response;
	}

	/**
	 * @author Warren
	 * @param mobile    手机号
	 * @param send_type 发送类型 ->学生用户 ->教师用户
	 * @param request   请求对象，获取客户端ip地址使用
	 * @return EducationSMSResponse
	 * @description 根据手机号给用户发送短信
	 * @date Nov 5, 2018
	 */
	public EducationSMSResponse getSMS(String mobile, int sendType, String ip) {
		HttpRequestCaller caller = createCaller(EducationSMSResponse.class);
		Map<String, String> params = new HashMap<String, String>();
		params.put("mobile", mobile);
		params.put("ip", ip);
		params.put("sendType", String.valueOf(sendType));
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_SMS_GET;
		EducationSMSResponse response = (EducationSMSResponse) caller.request(path, RequestMethod.GET, params);
		return response;
	}

	/**
	 * 
	 * @author Warren
	 * @param id
	 * @return EducationStudentResponse
	 * @description
	 * @date Nov 20, 2018
	 */
	public EducationStudentResponse getStudent(Long id) {
		HttpRequestCaller caller = createCaller(EducationStudentResponse.class);
		Map<String, String> params = new HashMap<String, String>();
		params.put("id", String.valueOf(id));
		// http://localhost:8090/education-api/getStudentAPI
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_STUDENT_GET_BY_ID;
		EducationStudentResponse response = (EducationStudentResponse) caller.request(path, RequestMethod.GET, params);
		return response;
	}

	/**
	 * @author Warren
	 * @param student
	 * @return ResponseBean
	 * @description 注册学生
	 * @date Nov 5, 2018
	 */
	public ResponseBean register(EducationStudentBean student) {
		HttpRequestCaller caller = createCaller(ResponseBean.class);
		Map<String, String> params = new HashMap<String, String>();
		if(student.getName()!=null) {
			params.put("name", student.getName());
		}
		
		if(student.getMobile()!=null) {
			params.put("mobile", student.getMobile());
		}
		
		if(student.getPassword()!=null) {
			params.put("password", student.getPassword());
		}
		
		if(student.getAge()!= null) {
			params.put("age", String.valueOf(student.getAge()));
		}
		
		if(student.getSex()!= null) {
			params.put("sex", String.valueOf(student.getSex()));
		}
		
		if(student.getHeadImage()!= null) {
			params.put("headImage", student.getHeadImage());
		}
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_STUDENT_REGISTER;
		ResponseBean response = (ResponseBean) caller.request(path, RequestMethod.GET, params);
		return response;
	}

	/**
	 * @author Warren
	 * @param mobile
	 * @param password
	 * @return EducationStudentResponse
	 * @description app端根据账号和密码请求登录
	 * @date Nov 6, 2018
	 */
	public EducationStudentResponse studentLogin(String mobile, String password) {
		HttpRequestCaller caller = createCaller(EducationStudentResponse.class);
		Map<String, String> params = new HashMap<String, String>();
		params.put("mobile", mobile);
		params.put("password", password);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_STUDENT_LOGIN;
		EducationStudentResponse response = (EducationStudentResponse) caller.request(path, RequestMethod.GET, params);
		return response;
	}

	/**
	 * @author Warren
	 * @param mobile
	 * @return ResponseBean
	 * @description 学生退出
	 * @date Nov 6, 2018
	 */
	public ResponseBean exitStudent(String mobile) {
		HttpRequestCaller caller = createCaller(ResponseBean.class);
		Map<String, String> params = new HashMap<String, String>();
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_STUDENT_EXIT;
		params.put("mobile", mobile);
		ResponseBean response = (ResponseBean) caller.request(path, RequestMethod.GET, params);
		return response;
	}

	/**
	 * @author Warren
	 * @param mobile   手机号(相当于账号)
	 * @param password 新密码
	 * @return ResponseBean
	 * @description 重置密码
	 * @date Nov 6, 2018
	 */
	public ResponseBean resetPwd(String mobile, String password) {
		HttpRequestCaller caller = createCaller(ResponseBean.class);
		Map<String, String> params = new HashMap<String, String>();
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_STUDENT_RESET_PASSWORD;
		params.put("mobile", mobile);
		params.put("password", password);
		ResponseBean response = (ResponseBean) caller.request(path, RequestMethod.GET, params);
		return response;
	}

	/**
	 * @author Warren
	 * @param mobile
	 * @return ResponseBean
	 * @description 根据手机号查询是否已注册
	 * @date Nov 7, 2018
	 */
	public ResponseBean mobileIsRepeat(String mobile) {
		HttpRequestCaller caller = createCaller(ResponseBean.class);
		Map<String, String> params = new HashMap<String, String>();
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_STUDENT_MOBILE_ISREPEAT;
		params.put("mobile", mobile);
		ResponseBean response = (ResponseBean) caller.request(path, RequestMethod.GET, params);
		return response;
	}
	
	/**
	 * @author Warren
	 * @param educationStudent
	 * @param file
	 * @param schoolId
	 * @param gradeId
	 * @param classId
	 * @param request
	 * @return ResponseBean
	 * @description 修改学生信息
	 * @date Nov 20, 2018
	 */
	public ResponseBean updateStudentInfo(EducationStudent educationStudent,MultipartFile file,String schoolId,String gradeId,String classId,HttpServletRequest request) {	
		String tempFilePath = null;
		try {
			MultiValueMap<String, Object> params = new LinkedMultiValueMap<String, Object>();
			params.add("schoolId", schoolId);
			params.add("gradeId", gradeId);
			params.add("classId", classId);
			params.add("educationStudentJSON", JSONObject.toJSONString(educationStudent));
			String appAddress = request.getScheme() + "://" +request.getServerName()+ ":" + request.getServerPort() + "/";
			params.add("appAddress", appAddress);
			if(file !=null && !file.isEmpty()) {
				File tempFile = new File(UUID.randomUUID().toString() + file.getOriginalFilename());
				tempFilePath = tempFile.getAbsolutePath();
				System.out.println(tempFile.getAbsolutePath());
				FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile);
				FileSystemResource fileSystemResource = new FileSystemResource(tempFile);
				params.add("file", fileSystemResource);
			}
			String path = iEducationPahtService.getEducationPath() + ApiPath.API_STUDENT_UPDATE_INFO;
			HttpHeaders headers = new HttpHeaders();
			headers.set("Content-Type", "multipart/form-data");
			HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<MultiValueMap<String, Object>>(params,headers);
			ResponseBean responseBean = restTemplate.postForObject(path, requestEntity, ResponseBean.class);
			return responseBean;
		}catch(Exception e) {
			
		}finally {
			if(tempFilePath!=null) {
				File f = new File(tempFilePath);
				if(f.exists()) {
					f.delete();
				}
			}
		}
		
		return null;
	}
	
	/**
	 * @author Warren
	 * @param mobile 手机号
	 * @param oldPassword 原密码
	 * @param newPassword 新密码
	 * @return ResponseBean
	 * @description 修改密码
	 * @date Nov 20, 2018
	 */
	public ResponseBean changePwd(String mobile,String oldPassword,String newPassword) {
		HttpRequestCaller caller = createCaller(ResponseBean.class);
		Map<String, String> params = new HashMap<String, String>();
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_STUDENT_CHANGE_PWD;
		params.put("mobile", mobile);
		params.put("oldPassword", oldPassword);
		params.put("newPassword", newPassword);
		ResponseBean response = (ResponseBean) caller.request(path, RequestMethod.GET, params);
		return response;
	}
	
	/**
	 * @author Warren
	 * @param groupId 
	 * @param studentId
	 * @return ResponseBean
	 * @description 学生主动退出班群
	 * @date Nov 20, 2018
	 */
	public ResponseBean exitGroup(Long groupId,Long studentId) {
		HttpRequestCaller caller = createCaller(ResponseBean.class);
		Map<String, String> params = new HashMap<String, String>();
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_STUDENT_EXIT_GROUP;
		params.put("groupId", String.valueOf(groupId));
		params.put("studentId", String.valueOf(studentId));
		ResponseBean response = (ResponseBean) caller.request(path, RequestMethod.GET, params);
		return response;
	}
	// -------------------------------Teacher---------------------------------------

	/**
	 * @Description 根据手机号查询 教师用户是否存在
	 * @author Leon
	 * @date Nov 5, 2018
	 * @param
	 * @return EducationTeacherResponse
	 */
	public EducationTeacherResponse findEducationTeacherByMobile(String mobile) {
		System.out.println("api caller :" + mobile);
		HttpRequestCaller caller = createCaller(EducationTeacherResponse.class);
		Map<String, String> params = new HashMap<String, String>();
		params.put("mobile", mobile);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_FIND_TEACHER_PATH;
		EducationTeacherResponse response = (EducationTeacherResponse) caller.request(path, RequestMethod.GET, params);
		return response;
	}
	
	/**
	 * @Description 根据 手机号 或 姓名进行查询
	 * @author Leon
	 * @date   Nov 12, 2018
	 * @param  
	 * @return ResponseListBean<EducationTeacher>
	 */
	@SuppressWarnings("unchecked")
	public ResponseListBean<EducationTeacher> findTeacherByMobileOrName(String content){
		System.out.println("api apiCaller ========================");
		System.out.println("content: "+content);
		HttpRequestCaller caller = createCaller(ResponseListBean.class);
		Map<String, String> params = new HashMap<String, String>();
		params.put("content", content);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_FIND_TEACHER_BY_MOBILE_OR_NAME;
		ResponseListBean<EducationTeacher> response = (ResponseListBean<EducationTeacher>) caller.request(path, RequestMethod.GET, params);
		return response;
	}
	
	/**
	 * @Description 教师端登录
	 * @author Leon
	 * @date Nov 6, 2018
	 * @param
	 * @return EducationTeacherResponse
	 */
	public EducationTeacherResponse login(String mobile, String password) {
		System.out.println("api caller login:" + mobile + " " + password);
		HttpRequestCaller caller = createCaller(EducationTeacherResponse.class);
		Map<String, String> params = new HashMap<String, String>();
		params.put("mobile", mobile);
		params.put("password", password);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_TEACHER_LOGIN;
		EducationTeacherResponse response = (EducationTeacherResponse) caller.request(path, RequestMethod.GET, params);
		return response;
	}

	/**
	 * @Description 教师端退出登录
	 * @author Leon
	 * @date Nov 6, 2018
	 * @param
	 * @return EducationTeacherResponse
	 */
	public EducationTeacherResponse quit(String mobile) {
		System.out.println("api caller quit:" + mobile);
		HttpRequestCaller caller = createCaller(EducationTeacherResponse.class);
		Map<String, String> params = new HashMap<String, String>();
		params.put("mobile", mobile);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_TEACHER_QUIT;
		EducationTeacherResponse response = (EducationTeacherResponse) caller.request(path, RequestMethod.GET, params);
		return response;
	}

	/**
	 * @Description 教师端 忘记密码
	 * @author Leon
	 * @date Nov 6, 2018
	 * @param
	 * @return EducationTeacherResponse
	 */
	public EducationTeacherResponse ForgetPassword(String mobile, String password) {
		System.out.println("api caller ForgetPassword:" + mobile + " " + password);
		HttpRequestCaller caller = createCaller(EducationTeacherResponse.class);
		Map<String, String> params = new HashMap<String, String>();
		params.put("mobile", mobile);
		params.put("password", password);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_TEACHER_FORGETPASSWORD;
		EducationTeacherResponse response = (EducationTeacherResponse) caller.request(path, RequestMethod.GET, params);
		return response;
	}


	/**
	 * @Description 注册成功保存 用户手机号和密码
	 * @author Leon
	 * @param  
	 * @date Nov 7, 2018
	 * @param
	 * @return EducationTeacherResponse
	 */
	public EducationTeacherResponse saveTeacherMobileAndPassword(String mobile, String password) {
		HttpRequestCaller caller = createCaller(EducationTeacherResponse.class);
		Map<String, String> params = new HashMap<String, String>();
		params.put("mobile", mobile);
		params.put("password", password);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_TEACHER_SAVE_TEACHER_MOBILE_PASSWORD;
		EducationTeacherResponse response = (EducationTeacherResponse) caller.request(path, RequestMethod.GET, params);
		return response;
	}



	/**
	 * @Description 完善教师信息
	 * @author Leon
	 * @date Nov 8, 2018
	 * @param
	 * @return EducationTeacherResponse
	 */
	public EducationTeacherResponse perfectTeacherInfo(EducationTeacher teacher, String schoolId, String subjectId) {
		HttpRequestCaller caller = createCaller(EducationTeacherResponse.class);
		Map<String, String> params = new HashMap<String, String>();
		params.put("headImage", teacher.getHeadImage());
		params.put("name", teacher.getName());
		params.put("mobile", teacher.getMobile());
		params.put("createTime", teacher.getCreateTime());
		params.put("teacherToken", teacher.getTeacherToken());
		params.put("schoolId", schoolId);
		params.put("subjectId", subjectId);
		System.out.println("schoolId" + schoolId);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_TEACHER_PERFECT_TEACHER_INFO;
		EducationTeacherResponse response = (EducationTeacherResponse) caller.request(path, RequestMethod.GET, params);
		return response;
	}

	/**
	 * @Description 退出群组
	 * @author Leon
	 * @date   Nov 19, 2018
	 * @param  
	 * @return ResponseBean
	 */
	public ResponseBean quitGroup(String groupId,String teacherId) {
		HttpRequestCaller caller = createCaller(EducationTeacherResponse.class);
		Map<String, String> params = new HashMap<String, String>();
		params.put("groupId", groupId);
		params.put("teacherId", teacherId);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_TEACHER_QUIT_GROUP;
		EducationTeacherResponse response = (EducationTeacherResponse) caller.request(path, RequestMethod.GET, params);
		return response;
	}
	
	/**
	 * @Description 修改密码
	 * @author Leon
	 * @date   Nov 27, 2018
	 * @param  
	 * @return ResponseBean
	 */
	public ResponseBean changePassword(String id,String oldPassword,String newPassword) {
		HttpRequestCaller caller = createCaller(ResponseBean.class);
		Map<String, String> params = new HashMap<String, String>();
		params.put("id",id);
		params.put("oldPassword", oldPassword);
		params.put("newPassword", newPassword);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_CHANGE_TEACHER_PASSWORD;
		ResponseBean response = (ResponseBean) caller.request(path, RequestMethod.GET, params);
		return response;
	}
	// -----------------------------------------ADMIN-------------------------------------------------------------
	/**
	 * 根据管理员的名字和密码查询数据库中是否有符合的数据
	 * 
	 * @author Brooks
	 * @param 管理员的名字和密码
	 * @date Oct 24, 2018
	 * @return 返回查询到的管理员信息
	 */
	public EducationAdminResponse getAdmin(String name, String password) {
		HttpRequestCaller caller = createCaller(EducationAdminResponse.class);

		Map<String, String> params = new HashMap<String, String>();
		params.put("name", name);
		params.put("password", password);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GET_ADMIN_PATH;
		EducationAdminResponse response = (EducationAdminResponse) caller.request(path, RequestMethod.GET, params);
		return response;
	}

	/**
	 * 根据用户名查询用户信息
	 * 
	 * @author Arwen Liu
	 * @date 2018-11-01
	 * @param name
	 * @return EducationAdminResponse
	 */
	public EducationAdminResponse findAdminByName(String name) {
		HttpRequestCaller caller = createCaller(EducationAdminResponse.class);

		Map<String, String> params = new HashMap<String, String>();
		params.put("name", name);
		String path = iEducationPahtService.getEducationPath() + "findAdminByName";

		EducationAdminResponse response = (EducationAdminResponse) caller.request(path, RequestMethod.GET, params);
		return response;
	}

	/**
	 * @Description 管理员修改密码
	 * @author Jason
	 * @date Nov 15, 2018
	 * @param oldPassword
	 * @param newPassword
	 * @return
	 */
	public EducationAdminResponse updateAdmin(String name ,String oldPassword, String newPassword) {
		
		HttpRequestCaller caller = createCaller(EducationAdminResponse.class);
		Map<String, String> params = new HashMap<String, String>();
		params.put("name", name);
		params.put("oldPassword", oldPassword);
		params.put("newPassword", newPassword);
		String path = iEducationPahtService.getEducationPath() +  ApiPath.API_UPDATE_ADMIN_PATH;
		EducationAdminResponse response = (EducationAdminResponse) caller.request(path, RequestMethod.GET, params);
		
		return response;
	}

	/**
	 * @Description 查询所有符合条件的老师
	 * @author Jason
	 * @date Nov 20, 2018
	 * @param teacher
	 * @param currentPage
	 * @param pageSize
	 * @return
	 */
	public PageBean getTeacher(EducationTeacher teacher, Integer currentPage, Integer pageSize) {
		
		HttpRequestCaller caller = createCaller(PageBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GET_TEACHER_PATH;
		Map<String ,String> params = new HashMap<>();
		params.put("teacher", JsonUtil.beanToJson(teacher));
		params.put("currentPage", currentPage.toString());
		params.put("pageSize", pageSize.toString());
		Object request = caller.request(path, RequestMethod.GET,params);
		PageBean response = (PageBean) request;
		
		return response;
	}

	/**
	 * @Description 根据ID删除老师
	 * @author Jason
	 * @date Nov 6, 2018
	 * @param teacherId
	 * @return
	 */
	public EducationTeacherResponse deleteTeacherById(Integer teacherId) {

		HttpRequestCaller caller = createCaller(EducationTeacherResponse.class);
		Map<String, String> params = new HashMap<String, String>();
		params.put("teacherId", teacherId.toString());
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_DEL_TEACHER_PATH;
		EducationTeacherResponse response = (EducationTeacherResponse) caller.request(path, RequestMethod.GET, params);

		return response;
	}



	/**
	 * 
	 * @Description 根据ID查询老师
	 * @author Jason
	 * @date Nov 7, 2018
	 * @param teacherId
	 * @return
	 */
	public EducationTeacherResponse findTeacherById(Integer teacherId) {

		HttpRequestCaller caller = createCaller(EducationTeacherResponse.class);
		Map<String, String> params = new HashMap<String, String>();
		params.put("teacherId", teacherId.toString());
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_FIND_TEACHER_BYID_PATH;		
		EducationTeacherResponse response = (EducationTeacherResponse) caller.request(path, RequestMethod.GET, params);

		return response;
	}
	
	/**
	 * 
	 * @Description 更新老师信息
	 * @author Jason
	 * @date Nov 7, 2018
	 * @param educationTeacher
	 * @return
	 */
	public EducationTeacherResponse updateTeacher(EducationTeacher educationTeacher) {
		HttpRequestCaller caller = createCaller(EducationTeacherResponse.class);
		Map<String, String> params = new HashMap<String, String>();
		params.put("educationTeacher", JsonUtil.beanToJson(educationTeacher));
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_UPDATE_TEACHER_PATH;
		EducationTeacherResponse response = (EducationTeacherResponse) caller.request(path, RequestMethod.GET, params);
		return response;
	}
	
	/**
	 * @Description 添加老师信息
	 * @author Jason
	 * @date Nov 9, 2018
	 * @param educationTeacher
	 * @return
	 */
	public EducationTeacherResponse addTeacher(EducationTeacher educationTeacher) {
		
		HttpRequestCaller caller = createCaller(EducationTeacherResponse.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_ADD_TEACHER_PATH;
		Map<String, String> params = new HashMap<String, String>();
		params.put("educationTeacher", JsonUtil.beanToJson(educationTeacher));
		EducationTeacherResponse response = (EducationTeacherResponse) caller.request(path, RequestMethod.GET, params);
		
		return response;
	}
	
	/**
	 * @Description 根据条件搜索老师
	 * @author Jason
	 * @date Nov 12, 2018
	 * @param teacher
	 * @return
	 */
	public ResponseListBean<EducationTeacher> findTeacherByCondition(EducationTeacher educationTeacher) {
		
		HttpRequestCaller caller = createCaller(ResponseListBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_FIND_TEACHER_BY_CONDITION_PATH;
		Map<String, String> params = new HashMap<String, String>();
		params.put("educationTeacher", JsonUtil.beanToJson(educationTeacher));
		ResponseListBean<EducationTeacher> response  = (ResponseListBean<EducationTeacher>) caller.request(path, RequestMethod.GET,params);
		
		return response;
	}
	
	/**
	 * @Description 查找所有学生信息
	 * @author Jason
	 * @param pageSize 
	 * @param currentPage 
	 * @param student 
	 * @date Nov 8, 2018
	 * @return
	 */
	public PageBean getStudent(EducationStudent student, Integer currentPage, Integer pageSize) {
		
		HttpRequestCaller caller = createCaller(PageBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GET_STUDENT_PATH;
		Map<String, String> params = new HashMap<String, String>();
		params.put("student", JsonUtil.beanToJson(student));
		params.put("currentPage", currentPage.toString());
		params.put("pageSize", pageSize.toString());
		PageBean response = (PageBean) caller.request(path, RequestMethod.GET,params);
		
		return response;
	}
	/**
	 * @Description 根据ID删除学生
	 * @author Jason
	 * @date Nov 8, 2018
	 * @param studentId
	 * @return
	 */
	public EducationStudentResponse deleteStudentById(Integer studentId) {

		HttpRequestCaller caller = createCaller(EducationStudentResponse.class);
		Map<String, String> params = new HashMap<String, String>();
		params.put("studentId", studentId.toString());
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_DEL_STUDENT_PATH;
		EducationStudentResponse response = (EducationStudentResponse) caller.request(path, RequestMethod.GET,params);

		return response;
	}

	/**
	 * 
	 * @Description 根据ID查询学生
	 * @author Jason
	 * @date Nov 8, 2018
	 * @param studentId
	 * @return
	 */
	public EducationStudentResponse findStudentById(Integer studentId) {
		
		HttpRequestCaller caller = createCaller(EducationStudentResponse.class);
		Map<String, String> params = new HashMap<String, String>();
		params.put("studentId", studentId.toString());
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_FIND_STUDENT_BYID_PATH;
		EducationStudentResponse response = (EducationStudentResponse) caller.request(path, RequestMethod.GET,params);
		
		return response;
	}
	
	/**
	 * 
	 * @Description 更新学生信息
	 * @author Jason
	 * @date Nov 8, 2018
	 * @param educationStudent
	 * @return
	 */
	public EducationStudentResponse updateStudent(EducationStudent educationStudent) {
		
		HttpRequestCaller caller = createCaller(EducationStudentResponse.class);
		Map<String, String> params = new HashMap<String, String>();
		System.out.println(params.toString());
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_UPDATE_STUDENT_PATH;
		params.put("educationStudent", JsonUtil.beanToJson(educationStudent));
		EducationStudentResponse response = (EducationStudentResponse) caller.request(path, RequestMethod.GET,params);
		
		return response;
	}
	/**
	 * @Description 添加学生信息
	 * @author Jason
	 * @date Nov 9, 2018
	 * @param educationStudent
	 * @return
	 */
	public EducationStudentResponse addStudent(EducationStudent educationStudent) {
		
		HttpRequestCaller caller = createCaller(EducationStudentResponse.class);
		Map<String, String> params = new HashMap<String, String>();
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_ADD_STUDENT_PATH;
		params.put("educationStudent", JsonUtil.beanToJson(educationStudent));
		EducationStudentResponse response = (EducationStudentResponse) caller.request(path, RequestMethod.GET,params);
		
		return response;
	}
	
	/**
	 * @Description 根据条件搜索学生
	 * @author Jason
	 * @date Nov 12, 2018
	 * @param student
	 * @return
	 */
	public ResponseListBean<EducationStudent> findStduentByCondition(EducationStudent educationStudent) {
		
		HttpRequestCaller caller = createCaller(ResponseListBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_FIND_STUDENT_BY_CONDITION_PATH;
		Map<String, String> params = new HashMap<String, String>();
		params.put("educationStudent", JsonUtil.beanToJson(educationStudent));
		ResponseListBean<EducationStudent> response  = (ResponseListBean<EducationStudent>) caller.request(path, RequestMethod.GET,params);
		
		return response;
	}
	
	// =============================Grade=================================
	
	/**
	 * @Description 查询所有年级
	 * @author Leon
	 * @date   Nov 12, 2018
	 * @param  
	 * @return ResponseListBean<EducationGradeBean>
	 */
	@SuppressWarnings("unchecked")
	public ResponseListBean<EducationGradeBean> getAllGrade() {
		HttpRequestCaller caller = createCaller(ResponseListBean.class);
		Map<String, String> params = new HashMap<String, String>();
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GRADE_GETALL;
		ResponseListBean<EducationGradeBean> response = (ResponseListBean<EducationGradeBean>) caller.request(path,RequestMethod.GET, params);
		return response;
	}

	/**
	 * @Description 完善教师的 班级信息
	 * @author Leon
	 * @date   Nov 12, 2018
	 * @param  
	 * @return EducationTeacherGradeClassResponse
	 */
	public EducationTeacherGradeClassResponse batchSaveGradeAndClass(String params) {
		HttpRequestCaller caller = createCaller(EducationTeacherGradeClassResponse.class);
		Map<String, String> map = new HashMap<String, String>();
		map.put("params", params);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GRADE_BATCH_SAVE_GRADE_AND_CLASS;
		EducationTeacherGradeClassResponse response = (EducationTeacherGradeClassResponse) caller.request(path,RequestMethod.GET, map);
		return response;
	}

	// --------------------------------------------------------School---------------------------------------------------------------

	/**
	 * @author Warren
	 * @return ResponseListBean<EducationSchoolBean>

	 * @description 获取所有学校列表
	 * @date Nov 8, 2018
	 */
	public ResponseListBean<EducationSchoolBean> getSchoolList() {
		HttpRequestCaller caller = createCaller(ResponseListBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_SCHOOL_LIST;
		@SuppressWarnings("unchecked")

		ResponseListBean<EducationSchoolBean> responselistBean = (ResponseListBean<EducationSchoolBean>) caller.request(path, RequestMethod.GET);
		return responselistBean;
	}

	/**
	 * @author Warren
	 * @return ResponseListBean<EducationSchoolBean>
	 * @description 根据省市区列出所有学校
	 * @date Nov 8, 2018
	 */
	public ResponseListBean<EducationSchoolBean> getSchoolListByProvinceAndCityAndArea(EducationSchool educationSchool) {
		HttpRequestCaller caller = createCaller(ResponseListBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_SCHOOL_LIST_BY_PROVINCEANDCITYANDAREA;
		Map<String, String> params = new HashMap<String, String>();
		if (educationSchool.getProvince() != null && !educationSchool.getProvince().equals("")) {
			params.put("province", educationSchool.getProvince());
		}
		if (educationSchool.getCity() != null && !educationSchool.getCity().equals("")) {
			params.put("city", educationSchool.getCity());
		}
		if (educationSchool.getArea() != null && !educationSchool.getArea().equals("")) {
			params.put("area", educationSchool.getArea());
		}
		if (educationSchool.getName() != null && !educationSchool.getName().equals("")) {
			params.put("name", educationSchool.getName());
		}
		@SuppressWarnings("unchecked")
		ResponseListBean<EducationSchoolBean> responselistBean = ( ResponseListBean<EducationSchoolBean>) caller.request(path, RequestMethod.GET,params);
		return responselistBean;
	}
	
	/**
	 * @Description 添加学校
	 * @author Jason
	 * @date Nov 13, 2018
	 * @param school
	 * @return
	 */
	public EducationSchoolResponse addSchool(EducationSchool educationSchool) {
		
		HttpRequestCaller caller = createCaller(EducationSchoolResponse.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_ADD_SCHOOL_PATH;
		Map<String, String> params = new HashMap<String, String>();
		params.put("educationSchool", JsonUtil.beanToJson(educationSchool));
		EducationSchoolResponse response = (EducationSchoolResponse) caller.request(path, RequestMethod.GET, params);
		
		return response;
	}

	/**
	 * @Description 根据ID查找学校
	 * @author Jason
	 * @date Nov 14, 2018
	 * @param schoolId
	 * @return
	 */
	public EducationSchoolResponse findSchoolById(Integer schoolId) {

		HttpRequestCaller caller = createCaller(EducationSchoolResponse.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_FIND_SCHOOL_BYID_PATH;
		Map<String, String> params = new HashMap<String, String>();
		params.put("schoolId", schoolId.toString());
		EducationSchoolResponse response = (EducationSchoolResponse) caller.request(path, RequestMethod.GET, params);
		
		return response;
	}

	/**
	 * @Description 更新学校
	 * @author Jason
	 * @date Nov 14, 2018
	 * @param school
	 * @return
	 */
	public EducationSchoolResponse updateSchool(EducationSchool educationSchool) {

		HttpRequestCaller caller = createCaller(EducationSchoolResponse.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_UPDATE_SCHOOL_PATH;
		Map<String, String> params = new HashMap<String, String>();
		params.put("educationSchool", JsonUtil.beanToJson(educationSchool));
		EducationSchoolResponse response = (EducationSchoolResponse) caller.request(path, RequestMethod.GET, params);
		
		return response;
	}

	/**
	 * @Description 删除学校
	 * @author Jason
	 * @date Nov 14, 2018
	 * @param schoolId
	 * @return
	 */
	public EducationSchoolResponse deleteSchool(Integer schoolId) {
		
		HttpRequestCaller caller = createCaller(EducationSchoolResponse.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_DELETE_SCHOOL_PATH;
		Map<String, String> params = new HashMap<String, String>();
		params.put("schoolId", schoolId.toString());
		EducationSchoolResponse response = (EducationSchoolResponse) caller.request(path, RequestMethod.GET, params);
		
		return response;
	}



	/**
	 * @author Warren
	 * @param id       学生id
	 * @param schoolId 学校id
	 * @return Map<String,Object>
	 * @description
	 * @date Nov 8, 2018
	 */

	public ResponseBean selectSchool(Long id, Long schoolId) {
		HttpRequestCaller caller = createCaller(ResponseBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_SCHOOL_SELECT;
		Map<String, String> params = new HashMap<String, String>();
		params.put("id", String.valueOf(id));
		params.put("schoolId", String.valueOf(schoolId));

		ResponseBean responseBean = (ResponseBean) caller.request(path, RequestMethod.GET, params);
		return responseBean;
	}

	// -----------------------------Class------------------------------------

	@SuppressWarnings("unchecked")
	public ResponseListBean<EducationClassBean> getClassList() {
		HttpRequestCaller caller = createCaller(ResponseListBean.class);
		Map<String, String> params = new HashMap<String, String>();
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_CLASS_LIST;
		ResponseListBean<EducationClassBean> response = (ResponseListBean<EducationClassBean>) caller.request(path, RequestMethod.GET,params);
		return response;
	}
	//-------------------------------------Subject------------------------
	/**
	 * @Description 查询所有学科
	 * @author Jason
	 * @date Nov 8, 2018
	 * @return
	 */
	public ResponseListBean<EducationSubjectBean> getSubjectList() {
		
		HttpRequestCaller caller = createCaller(ResponseListBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GET_SUBJECTLIST_PATH;
		Object object = caller.request(path, RequestMethod.GET);
		ResponseListBean<EducationSubjectBean> response = (ResponseListBean<EducationSubjectBean>) object;  

		return response;
	}

	//--------------------------------------------------Group----------------------------------------------------------------------
	
	/**
	 * @author Warren
	 * @param id 群号
	 * @return Map<String,Object>
	 * @description id为群号(10001开始增长)，根据群号搜索班群
	 * @date Nov 9, 2018
	 */
	public EducationGroupResponse searchGroupById(Long id) {
		HttpRequestCaller caller = createCaller(EducationGroupResponse.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GROUP_SEARCH_BY_Id;
		Map<String, String> params = new HashMap<String, String>();
		params.put("id", String.valueOf(id));
		EducationGroupResponse educationGroupResponse = (EducationGroupResponse)caller.request(path, RequestMethod.GET, params);
		return educationGroupResponse;
	}
	
	/**
	 * @author Warren

	 * @param userId 申请的用户id
	 * @param groupId 申请的班群号
	 * @param sendType 申请类型,教师或学生
	 * @return ResponseBean
	 * @description 申请加入班群
	 * @date Nov 19, 2018
	 */
	public ResponseBean applyGroup(Long userId, Long groupId, int sendType) {
		HttpRequestCaller caller = createCaller(ResponseBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GROUP_APPLY;
		Map<String, String> params = new HashMap<String, String>();
		params.put("userId", String.valueOf(userId));
		params.put("groupId", String.valueOf(groupId));
		params.put("sendType",  String.valueOf(sendType));
		ResponseBean responseBean = (ResponseBean)caller.request(path, RequestMethod.GET, params);
		return responseBean;
	}
	
	/**
	 * @author Warren
	 * @param id 申请班群消息id
	 * @param messageStatus 教师处理结果
	 * @return ResponseBean
	 * @description 教师处理班群申请
	 * @date Nov 13, 2018
	 */
	public ResponseBean applyGroupHandle(Long id, int messageStatus) {
		HttpRequestCaller caller = createCaller(ResponseBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GROUP_APPLY_HANDLE;
		Map<String, String> params = new HashMap<String, String>();
		params.put("id", String.valueOf(id));
		params.put("messageStatus", String.valueOf(messageStatus));
		ResponseBean responseBean = (ResponseBean)caller.request(path, RequestMethod.GET, params);
		return responseBean;
	}
	
	/**
	 * @author Warren
	 * @param studentId 学生id
	 * @return ResponseListBean<EducationGroup>
	 * @description 根据学生id获取学生的班群列表
	 * @date Nov 13, 2018
	 */
	public ResponseListBean<EducationGroup> findGroupByStudentId(Long studentId) {
		HttpRequestCaller caller = createCaller(ResponseListBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GROUP_FIND_BY_STUDENT_ID;
		Map<String, String> params = new HashMap<String, String>();
		params.put("studentId", String.valueOf(studentId));
		@SuppressWarnings("unchecked")
		ResponseListBean<EducationGroup> responseListBean = (ResponseListBean<EducationGroup>)caller.request(path, RequestMethod.GET, params);
		return responseListBean;
	}
	
	/**
	 * @author Warren
	 * @param ids
	 * @param groupId
	 * @return ResponseBean
	 * @description 班群内批量移除学生
	 * @date Nov 16, 2018
	 */
	public ResponseBean removeStudents(String[] ids,String groupId) {
		HttpRequestCaller caller = createCaller(ResponseBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GROUP_STUDENT_REMOVE;
		List<String> idsList = Arrays.asList(ids);
		String idsStr = idsList.toString().substring(1, idsList.toString().length()-1);
		Map<String, String> params = new HashMap<String, String>();
		params.put("groupId", groupId);
		params.put("ids", idsStr);
		ResponseBean responseBean = (ResponseBean)caller.request(path, RequestMethod.GET, params);
		return responseBean;
	}
	
	/**
	 * @Description 根据老师查询  老师已有的群组
	 * @author Leon
	 * @date   Nov 9, 2018
	 * @param  
	 * @return ResponseListBean<EducationGroupResponse>
	 */
	@SuppressWarnings("unchecked")
	public ResponseListBean<EducationGroupResponse> findGroupByTeacherId(String teacherId){
		HttpRequestCaller caller = createCaller(ResponseListBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GROUP_FIND_BY_TEACHER_ID;
		Map<String, String> params = new HashMap<String, String>();
		params.put("teacherId", teacherId);
		ResponseListBean<EducationGroupResponse> response = (ResponseListBean<EducationGroupResponse>)caller.request(path, RequestMethod.GET, params);
		return response;
	}
	
	/**
	 * @Description 创建班群
	 * @author Leon
	 * @date   Nov 12, 2018
	 * @param  
	 * @return EducationGroupResponse
	 */
	public EducationGroupResponse createGroups(String params) {
		HttpRequestCaller caller = createCaller(EducationGroupResponse.class);
		Map<String, String> map = new HashMap<String, String>();
		map.put("params", params);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GROUP_CREATE;
		EducationGroupResponse response = (EducationGroupResponse) caller.request(path,RequestMethod.GET, map);
		return response;
	}
	
	/**
	 * @Description 移除教师
	 * @author Leon
	 * @date   Nov 13, 2018
	 * @param  
	 * @return EducationGroupResponse
	 */
	public EducationGroupResponse removeTeacher(String teacherId,String groupId) {
		HttpRequestCaller caller = createCaller(EducationGroupResponse.class);
		Map<String, String> map = new HashMap<String, String>();
		map.put("teacherId", teacherId);
		map.put("groupId", groupId);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GROUP_REMOVE_TEACHER;
		EducationGroupResponse response = (EducationGroupResponse) caller.request(path,RequestMethod.GET, map);
		return response;
	}
	
	/**
	 * @Description 转让班群
	 * @author Leon
	 * @date   Nov 13, 2018
	 * @param  
	 * @return EducationGroupResponse
	 */
	public EducationGroupResponse transferGroup(String teacherId,String groupId) {
		HttpRequestCaller caller = createCaller(EducationGroupResponse.class);
		Map<String, String> map = new HashMap<String, String>();
		map.put("teacherId", teacherId);
		map.put("groupId", groupId);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GROUP_TRANSFER_GROUP;
		EducationGroupResponse response = (EducationGroupResponse) caller.request(path,RequestMethod.GET, map);
		return response;
	}
	
	/**
	 * @Description 修改班群
	 * @author Leon
	 * @date   Nov 14, 2018
	 * @param  
	 * @return EducationGroupResponse
	 */
	public EducationGroupResponse modifyGroup(EducationGroup group) {
		HttpRequestCaller caller = createCaller(EducationGroupResponse.class);
		Map<String, String> map = new HashMap<String, String>();
		String param = JsonUtil.beanToJson(group);
		map.put("param", param);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GROUP_MODIFY_GROUP;
		EducationGroupResponse response = (EducationGroupResponse) caller.request(path,RequestMethod.GET, map);
		return response;
	}
	
	/**
	 * @Description 删除群组
	 * @author Leon
	 * @date   Nov 14, 2018
	 * @param  
	 * @return EducationGroupResponse
	 */
	public EducationGroupResponse deleteGroupById(String groupId) {
		HttpRequestCaller caller = createCaller(EducationGroupResponse.class);
		Map<String, String> map = new HashMap<String, String>();
		map.put("groupId", groupId);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GROUP_DELETE_BY_ID;
		EducationGroupResponse response = (EducationGroupResponse) caller.request(path,RequestMethod.GET, map);
		return response;
	}

	/**
	 * @Description 查询符合条件的群组的信息
	 * @author Jason
	 * @date Nov 20, 2018
	 * @param schoolName
	 * @param currentPage
	 * @param pageSize
	 * @return
	 */
	public PageBean getAllGroup(String schoolName, Integer currentPage, Integer pageSize) {
		
		HttpRequestCaller caller = createCaller(PageBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GET_GROUP_PATH;
		Map<String, String> params = new HashMap<String, String>();
		params.put("schoolName", schoolName);
		params.put("currentPage", currentPage.toString());
		params.put("pageSize", pageSize.toString());
		Object request = caller.request(path, RequestMethod.GET,params);
		PageBean response = (PageBean) request;
		
		return response;
	}
	
	//----------------------------------------------Message--------------------------------------------------------------
	
	/**
	 * @author Warren
	 * @param studentId
	 * @param currentPage
	 * @param pageSize
	 * @return PageBean
	 * @description 根据页码、页数量、id查询学生的消息列表
	 * @date Nov 21, 2018
	 */
	public PageBean getALLMessageByStudentId(Long studentId,int currentPage,int pageSize) {
		HttpRequestCaller caller = createCaller(PageBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_MESSAGE_STUDENT_GETALL;
		Map<String, String> params = new HashMap<String, String>();
		params.put("studentId", String.valueOf(studentId));
		params.put("currentPage", String.valueOf(currentPage));
		params.put("pageSize", String.valueOf(pageSize));
		PageBean pageBean = (PageBean)caller.request(path, RequestMethod.GET, params);
		return pageBean;
	}
	
	/**
	 * @author Warren
	 * @param teacherId
	 * @param currentPage
	 * @param pageSize
	 * @return PageBean
	 * @description 根据页码、页数量、id查询教师的消息列表
	 * @date Nov 21, 2018
	 */
	public PageBean getALLMessageByTeacherId(Long teacherId,int currentPage,int pageSize) {
		HttpRequestCaller caller = createCaller(PageBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_MESSAGE_TEACHER_GETALL;
		Map<String, String> params = new HashMap<String, String>();
		params.put("teacherId", String.valueOf(teacherId));
		params.put("currentPage", String.valueOf(currentPage));
		params.put("pageSize", String.valueOf(pageSize));
		PageBean pageBean = (PageBean)caller.request(path, RequestMethod.GET, params);
		return pageBean;
	}
	
	/**
	 * @author Warren
	 * @return ResponseBean
	 * @description 根据id删除消息
	 * @date Nov 20, 2018
	 */
	public ResponseBean deleteMessageById(Long id) {
		HttpRequestCaller caller = createCaller(ResponseBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_MESSAGE_DELETE_BY_ID;
		Map<String, String> params = new HashMap<String, String>();
		params.put("id", String.valueOf(id));
		ResponseBean responseBean = (ResponseBean)caller.request(path, RequestMethod.GET, params);
		return responseBean;
	}
	
	/**
	 * @Description 修改教师个人信息
	 * @author Leon
	 * @date Nov 15, 2018
	 * @param
	 * @return EducationTeacherResponse
	 */
	public EducationTeacherResponse modifyTeacherInfo(HttpServletRequest request,EducationTeacher teacher, MultipartFile file) {
		System.out.println(teacher.getId());
		EducationTeacherResponse response = null;
		String tempFilePath = null;
		try {
			MultiValueMap<String, Object> params = new LinkedMultiValueMap<String, Object>();
			String bean = JsonUtil.beanToJson(teacher);
			params.add("bean", bean);
			if (null != file && !file.isEmpty()) {
				String url = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getServletContext().getContextPath();
				params.add("url", url);
				// 生成临时的文件,完成传输后再删除
				tempFilePath = System.getProperty("user.dir") + File.separator + UUID.randomUUID().toString()
						+".jpg";
				File tempFile = new File(tempFilePath);
				//file.transferTo(tempFile);
				FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile);
				FileSystemResource fileSystemResource = new FileSystemResource(tempFile);
				params.add("file", fileSystemResource);
			}
			String path = iEducationPahtService.getEducationPath() + ApiPath.API_TEACHER_MODIFY_TEACHER_INFO;
			HttpHeaders headers = new HttpHeaders();
			headers.set("Content-Type", "multipart/form-data");
			HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<MultiValueMap<String, Object>>(params,headers);
			//response = restTemplate.exchange(path, HttpMethod.POST, requestEntity,EducationTeacherResponse.class);
			response = restTemplate.postForObject(path, requestEntity, EducationTeacherResponse.class);
		} catch (Exception e) {
			System.out.println("出现异常");
			e.printStackTrace();
		} finally {
			if (null != tempFilePath && !tempFilePath.isEmpty()) {
				File deleteFile = new File(tempFilePath);
				if (deleteFile.exists()) {
					deleteFile.delete();
				}
			}
		}
		return response;
	}
	
	//-----------------------------------------------------subjectLesson---------------------------------------------------------------
	
	/**
	 * @author Warren
	 * @return ResponseListBean<EducationSubjectLesson>
	 * @description 查询所有课时
	 * @date Nov 20, 2018
	 */
	public ResponseListBean<EducationSubjectLesson> getALLSubjectLesson() {
		HttpRequestCaller caller = createCaller(ResponseListBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_SUBJECTLESSON_GETALL;
		@SuppressWarnings("unchecked")
		ResponseListBean<EducationSubjectLesson> responseListBean = (ResponseListBean<EducationSubjectLesson>)caller.request(path, RequestMethod.GET);
		return responseListBean;
	}
	
	/**
	 * @Description 根据课时 id  选择题目以及数量
	 * @author Leon
	 * @date   Nov 20, 2018
	 * @param  
	 * @return ResponseListBean<EducationSubjectLesson>
	 */
	public ResponseListBean<EducationSubjectLesson> selectTopicAndNumber(String lessonIds){
		HttpRequestCaller caller = createCaller(ResponseListBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_SUBJECTLESSON_SELECT_TOPIC_AND_NUMBER;
		Map<String, String> params = new HashMap<String, String>();
		params.put("lessonIds", lessonIds);
		@SuppressWarnings("unchecked")
		ResponseListBean<EducationSubjectLesson> lessonList = (ResponseListBean<EducationSubjectLesson>)caller.request(path, RequestMethod.GET, params);
		return lessonList;
	}
	
	/**
	 * @Description 根据选择的课时 题目数量  场景  以及 题目难度进行 智能组题
	 * @author Leon
	 * @date   Nov 21, 2018
	 * @param  params：[
	 * 					{lessonId:1,number:2},
	 * 					{lessonId:2,number:3}
	 * 				  ]
	 * 		   scenes: 场景
	 * 		   level ： 等级
	 * @return ResponseListBean<EducationQuestion>
	 */
	public ResponseListBean<EducationQuestion> getQuestionListByLesson(String params, String scenes, String level) {
		HttpRequestCaller caller = createCaller(ResponseListBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_SUBJECTLESSON_GET_QUESTION_LIST_By_LESSON;
		Map<String, String> map = new HashMap<String, String>();
		map.put("params", params);
		map.put("scenes", scenes);
		map.put("level", level);
		@SuppressWarnings("unchecked")
		ResponseListBean<EducationQuestion> questionList = (ResponseListBean<EducationQuestion>)caller.request(path, RequestMethod.GET, map);
		return questionList;
	}
	//---------------------------------------------------subject Unit ----------------------------------------------------------------------------
	/**
	 * @Description 根据年级和学科 查询单元和课时
	 * @author Leon
	 * @date   Nov 20, 2018
	 * @param  
	 * @return EducationSubjectUnit
	 */
	public ResponseListBean<EducationSubjectUnit> findUnitAndLesson(EducationSubjectUnit subjectUnit) {
		HttpRequestCaller caller = createCaller(ResponseListBean.class);
		String bean = JsonUtil.beanToJson(subjectUnit);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_SUBJECT_UNIT_FIND_BY_GRADE_AND_SUBJECT;
		Map<String, String> params = new HashMap<String, String>();
		params.put("bean", bean);
		ResponseListBean<EducationSubjectUnit> unitList = (ResponseListBean<EducationSubjectUnit>)caller.request(path, RequestMethod.GET, params);
		return unitList;
	}
	
	//--------------------------------------------------homework-------------------------------------------------------------------------
	
	/**
	 * @author Warren
	 * @param studentId
	 * @return ResponseListBean<EducationHomeWorkStudent>
	 * @description 根据学生id查询学生的作业列表(作业本)
	 * @date Nov 20, 2018
	 */
	public ResponseListBean<EducationHomeWorkStudent> getListByStudentId(Long studentId) {
		HttpRequestCaller caller = createCaller(ResponseListBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_HOMEWORK_STUDENT_LIST_BY_ID;
		Map<String, String> params = new HashMap<String, String>();
		params.put("studentId", String.valueOf(studentId));
		@SuppressWarnings("unchecked")
		ResponseListBean<EducationHomeWorkStudent> responseListBean = (ResponseListBean<EducationHomeWorkStudent>)caller.request(path, RequestMethod.GET, params);
		return responseListBean;
	}
	
	/**
	 * @author Warren
	 * @param homeworkId
	 * @return ResponseListBean<EducationHomeWorkQuestion>
	 * @description 根据作业id获得作业的所有题目
	 * @date Nov 22, 2018
	 */
	public ResponseListBean<EducationHomeWorkQuestion> getALLQuestionByHomeWorkId(Long homeworkId) {
		HttpRequestCaller caller = createCaller(ResponseListBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_HOMEWORK_QUESTION_GETALL;
		Map<String, String> params = new HashMap<String, String>();
		params.put("homeworkId", String.valueOf(homeworkId));
		@SuppressWarnings("unchecked")
		ResponseListBean<EducationHomeWorkQuestion> responseListBean = (ResponseListBean<EducationHomeWorkQuestion>)caller.request(path, RequestMethod.GET, params);
		return responseListBean;
	}
	
	/**
	 * @author Warren
	 * @param hqId 作业问题标识
	 * @param studentId 学生id
	 * @param answerId 问题选项id
	 * @return ResponseBean 
	 * @description
	 * @date Nov 22, 2018
	 */
	public ResponseBean answerHomeWorkQuestion(Long hqId, Long studentId, Long answerId) {
		HttpRequestCaller caller = createCaller(ResponseBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_HOMEWORK_QUESTION_ANSWER;
		Map<String, String> params = new HashMap<String, String>();
		params.put("hqId", String.valueOf(hqId));
		params.put("studentId", String.valueOf(studentId));
		params.put("answerId", String.valueOf(answerId));
		ResponseBean responseBean = (ResponseBean)caller.request(path, RequestMethod.GET, params);
		return responseBean;
	}
	
	/**
	 * @author Warren
	 * @param homeworkId
	 * @param studentId
	 * @param startTime
	 * @param endTime
	 * @return ResponseBean
	 * @description 学生提交作业
	 * @date Nov 22, 2018
	 */
	public ResponseBean studentCommitHomeWork(Long homeworkId,Long studentId,String startTime,String endTime) {
		HttpRequestCaller caller = createCaller(ResponseBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_HOMEWORK_STUDENT_COMMIT;
		Map<String, String> params = new HashMap<String, String>();
		params.put("homeworkId", String.valueOf(homeworkId));
		params.put("studentId", String.valueOf(studentId));
		params.put("startTime", startTime);
		params.put("endTime", endTime);
		ResponseBean responseBean = (ResponseBean)caller.request(path, RequestMethod.GET, params);
		return responseBean;
	}
	/**
	 * @Description 教师选择群组发布作业
	 * @author Leon
	 * @date Nov 22, 2018
	 * @param
	 * @return ResponseBean
	 */
	public ResponseBean publishHomeWork(String questionIds, String groupIds,String lessonIds, String startTime, String endTime,
			String teacherId) {
		HttpRequestCaller caller = createCaller(ResponseBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_PUBLISH_HOMEWORK;
		System.out.println("questionIds :" + questionIds);
		Map<String, String> params = new HashMap<String, String>();
		params.put("questionIds", questionIds);
		params.put("groupIds", groupIds);
		params.put("lessonIds", lessonIds);
		params.put("startTime", startTime);
		params.put("endTime", endTime);
		params.put("teacherId", teacherId);
		ResponseBean response = (ResponseBean) caller.request(path, RequestMethod.GET, params);
		return response;
	}
	
	/**
	 * @Description 根据教师id查询教师的发布的作业列表
	 * @author Leon
	 * @date   Nov 23, 2018
	 * @param  
	 * @return ResponseListBean<EducationHomeWork>
	 */
	public ResponseListBean<EducationHomeWork> findHomeWorkByTeacherId(String teacherId){
		HttpRequestCaller caller = createCaller(ResponseListBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_FIND_HOMEWORK_BY_TEACHER_ID;
		Map<String, String> params = new HashMap<String, String>();
		params.put("teacherId", teacherId);
		@SuppressWarnings("unchecked")
		ResponseListBean<EducationHomeWork> response = (ResponseListBean<EducationHomeWork>) caller.request(path, RequestMethod.GET, params);
		return response;
	}
	
	/**
	 * @Description 根据作业id 查看作业概览
	 * @author Leon
	 * @date   Nov 26, 2018
	 * @param  
	 * @return EducationHomeWorkResponse
	 */
	public EducationHomeWorkResponse findHomeWorkOverviewById(String id) {
		HttpRequestCaller caller = createCaller(EducationHomeWorkResponse.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_FIND_HOMEWORK_OVERVIEW_BY_ID;
		Map<String, String> params = new HashMap<String, String>();
		params.put("id", id);
		EducationHomeWorkResponse response = (EducationHomeWorkResponse) caller.request(path, RequestMethod.GET, params);
		return response;
	}
	
	/**
	 * @Description 根据作业id 删除作业
	 * @author Leon
	 * @date   Nov 26, 2018
	 * @param  
	 * @return ResponseBean
	 */
	public ResponseBean deleteHomeWorkById(String id) {
		HttpRequestCaller caller = createCaller(ResponseBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_DELETE_HOMEWORK_BY_ID;
		Map<String, String> params = new HashMap<String, String>();
		params.put("id", id);
		ResponseBean response = (ResponseBean) caller.request(path, RequestMethod.GET, params);
		return response;
	}
	
	/**
	 * @Description 获取学生作业概览
	 * @author Leon
	 * @date   Nov 27, 2018
	 * @param  
	 * @return EducationHomeWorkStudentResponse
	 */
	public EducationHomeWorkStudentResponse getStudentHomeWorkOverview(String id) {
		HttpRequestCaller caller = createCaller(EducationHomeWorkStudentResponse.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GET_STUDENT_HOMEWORK_OVERVIEW;
		Map<String, String> params = new HashMap<String, String>();
		params.put("id", id);
		EducationHomeWorkStudentResponse response = (EducationHomeWorkStudentResponse) caller.request(path, RequestMethod.GET, params);
		return response;
	}
	
	//--------------------------------------------------question-------------------------------------------------------------------------
	public PageBean getAllQuestion(EducationQuestion question, Integer currentPage, Integer pageSize) {
		
		HttpRequestCaller caller = createCaller(PageBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GET_QUESTION_PATH;
		Map<String, String> params = new HashMap<String, String>();
		params.put("question", JsonUtil.beanToJson(question));
		params.put("currentPage", currentPage.toString());
		params.put("pageSize", pageSize.toString());
		PageBean pageBean = (PageBean) caller.request(path, RequestMethod.GET,params);
		
		return pageBean;
	}
	/** 
	 * @Description 根据ID删除问题
	 * @author Jason
	 * @date Nov 23, 2018
	 * @param id
	 * @return
	 */
	public ResponseBean deleteQuestionById(Long id) {
		
		HttpRequestCaller caller = createCaller(ResponseBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_DELETE_QUESTION_PATH;
		Map<String, String> params = new HashMap<String, String>();
		params.put("Id", id.toString());
		ResponseBean response = (ResponseBean) caller.request(path, RequestMethod.GET,params);
		
		return response;
	}
	//------------------------------------------------subject--------------------------------------------------------------
	public ResponseListBean<EducationSubject> getAllSubject(){
		HttpRequestCaller caller = createCaller(ResponseListBean.class);
		String path = iEducationPahtService.getEducationPath() + ApiPath.API_GET_SUBJECTLIST_PATH;
		Map<String, String> params = new HashMap<String, String>();
		@SuppressWarnings("unchecked")
		ResponseListBean<EducationSubject> response = (ResponseListBean<EducationSubject>) caller.request(path, RequestMethod.GET, params);
		return response;
	}
}

